package com.ezbuy.common.bean;

import com.ezbuy.common.helper.NameHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * ezbuy 2018/12/1 下午5:13
 */
public class ProtoFile {

    private String name;
    private String packageName;
    private String grpcPackageName;
    private List<MessageType> messageTypes = new ArrayList<>();
    private List<EnumType> enumTypes = new ArrayList<>();
    private List<ServiceType> serviceTypes = new ArrayList<>();

    public String getName() {
        return NameHelper.getRealName(name);
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public List<MessageType> getMessageTypes() {
        return messageTypes;
    }

    public void setMessageTypes(List<MessageType> messageTypes) {
        this.messageTypes = messageTypes;
    }

    public List<EnumType> getEnumTypes() {
        return enumTypes;
    }

    public void setEnumTypes(List<EnumType> enumTypes) {
        this.enumTypes = enumTypes;
    }

    public List<ServiceType> getServiceTypes() {
        return serviceTypes;
    }

    public void setServiceTypes(List<ServiceType> serviceTypes) {
        this.serviceTypes = serviceTypes;
    }

    public void addMessageType(MessageType messageType) {
        this.messageTypes.add(messageType);
        messageType.setFile(this);
    }

    public void addEnumType(EnumType enumType) {
        this.enumTypes.add(enumType);
        enumType.setFile(this);
    }

    public void addSeiviceType(ServiceType serviceType) {
        this.serviceTypes.add(serviceType);
        serviceType.setFile(this);
    }

    public String getGrpcPackageName() {
        return grpcPackageName;
    }

    public void setGrpcPackageName(String grpcPackageName) {
        this.grpcPackageName = grpcPackageName;
    }

    @Override
    public String toString() {
        return "ProtoFile{" +
                "name='" + name + '\'' +
                ", packageName='" + packageName + '\'' +
                ", grpcPackageName='" + grpcPackageName + '\'' +
                ", messageTypes=" + messageTypes +
                ", enumTypes=" + enumTypes +
                ", serviceTypes=" + serviceTypes +
                '}';
    }
}
